'use strict';

/**
 * @ngdoc directive
 * @name myAppApp.directive:backBtn
 * @description
 * # backBtn
 */
angular.module('jgappApp')
    .directive('backBtn', ['Util', function(Util) {
        return {
            template: '<div class="backbtn">返回</div>',
            restrict: 'AE',
            replace: true,
            link: function postLink(scope, element, attrs) {
                // element.text('this is the backBtn directive');
                element.bind('click', function() {
                    if (attrs.cleancache != "no") {
                        Util.clearFormData();
                    }
                    var num = Util.getRelMoNum()
                    if (num) {
                        Util.setRelMoNum(0)
                    } else {
                        Util.clearTVType()
                    }
                    Util.goBack();
                });
            }
        };
    }]);
